package com.ibm.risk.irmp.base.auth.rest;

import com.ibm.risk.irmp.base.auth.entity.SystemPermission;
import com.ibm.risk.irmp.base.auth.service.IMenuManagementService;
import com.ibm.risk.irmp.base.auth.vo.UserMenuTreeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/v2/menu")
public class MenuManagementController {

    @Autowired
    private IMenuManagementService menuManagementService;

    /**
     * 获取菜单列表
     */
    @GetMapping(value = "/getMenulist")
    public List<UserMenuTreeVo> paramTables() {
        List<UserMenuTreeVo> dataTypes = menuManagementService.getMenuList();
        return dataTypes;
    }

    /**
     * 编辑菜单
     */
    @PostMapping(value = "/saveMenu")
    public Boolean saveMenu(@RequestBody SystemPermission entity) {
        Boolean result = menuManagementService.saveMenu(entity);
        return (result);
    }

    /**
     * 删除菜单
     */
    @DeleteMapping(value = "/deleteMenu")
    public Boolean deleteMenu(@RequestParam Long id) {
        Boolean result = menuManagementService.deleteMenu(id);
        return (result);
    }
}
